/**
 * https://www.luogu.com.cn/problem/P1883
 */

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int a[10010],b[10010],c[10010];
double eps=1e-9;
int n;
inline double f(double x,int i){
	return a[i]*(x*x)+b[i]*x+c[i];
}
double check(double x){
	double ans=f(x,1);
	for(int i=2;i<=n;++i)
	ans=max(ans,f(x,i));
	return ans;
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n;++i)
		    cin>>a[i]>>b[i]>>c[i];
		double left=0.0,right=1000.0;
			while(right-left>eps){
				double mid1=left+(right-left)/3.0;
			    double mid2=right-(right-left)/3.0;
				if(check(mid1)>check(mid2))
					left=mid1;
				else
				right=mid2;
			}
		printf("%0.4lf\n",check(left));
	}
	return 0;
}